var mRequest = require('../goodsDetailsService.js');
let app = getApp()
/**
 * 关注的人View
 */
Component({

  options: {
    // 在组件定义时的选项中启用多slot支持
    multipleSlots: true
  },

  /**
   * 组件的属性列表
   * 用于组件自定义设置
   */
  properties: {
    url:{
      type: String,
      value: '',
    },
    userName: {
      type: String,
      value: '',
    },
    userCity: {
      type: String,
      value: '',
    },
    isFollowVisible: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 私有数据,组件的初始数据
   * 可用于模版渲染
   */
  data: {
    isFans: true,
    foucesUserId: '' // 关注人的userid
  },

  /**
     * 组件的方法列表
     * 更新属性和数据的方法与更新页面数据的方法类似
     */
  methods: {


    /**
     * 查看是否关注过
     * 0没有，1已关注
     */
    showFans: function (foucesUserId) {
      var that = this
      var param = {
        userId: app.globalData.userId,
        foucesUserId: foucesUserId
      }
      this.setData({
        foucesUserId: foucesUserId
      })
      mRequest.getFansPeople(param,
        function (data) {
          console.log('查看是否关注过  成功')
          that.setData({
            isFans: data == 1 ? true: false
          })
        })
    },
  /**
   * 点击了发布者头像
   */
    clickReleasePeople:function(){
      wx.navigateTo({
        url: '/mineSubs/pages/homepage/personalhomepage?userId=' + this.data.foucesUserId,
      })
    },
    /**
     * 点击了关注下
     */
    clickFans: function () {
      var that = this
      var foucesUserId = ''
      var param = {
        userId: app.globalData.userId,
        foucesUserId: this.data.foucesUserId,
        flag: that.data.isFans ? 1 : 0
      }
      mRequest.setFansData(param,
        function (data) {
          that.setData({
            isFans: !that.data.isFans
          })
        })
    },
  }
})
